package br.com.projeto.task;

import java.sql.SQLException;
import java.util.List;

import br.com.projeto.MegaSenaApplication;
import br.com.projeto.model.Jogo;
import android.os.Handler;
import android.util.Log;

public class ListarJogosTask extends BaseTask<Void, Void, Void>{

	public ListarJogosTask(Handler handler) {
		super(handler);
	}

	@Override
	protected Void doInBackground(Void... params) {
		try {
			List<Jogo> list = MegaSenaApplication.getDataBaseHelper().getCadastroDao().queryForAll();
			handler.obtainMessage(MegaSenaApplication.HANDLE_LIST_OK, list).sendToTarget();
		} catch (SQLException e) {
			Log.e(TAG, "Error to get list of games: " + e);
		}
		return null;
	}
}
